package com.cloud.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cloud.mapper.EventWarnMapper;
import com.cloud.pojo.EventWarn;
import com.cloud.pojo.EventWarnExample;
import com.cloud.pojo.EventWarnExample.Criteria;
import com.cloud.service.EventWarnService;

@Service
public class EventWarnServiceImpl implements EventWarnService{
	
	@Autowired
	private EventWarnMapper eventWarnMapper;

	@Override
	public Integer addEventWarn(EventWarn eventWarn) {
		// TODO Auto-generated method stub
		eventWarn.setWarnTime(new Date(eventWarn.getWarnTimeLong()));
		int i = eventWarnMapper.insert(eventWarn);
//		System.out.println("i:"+i);
//		System.out.println("eventId:"+eventWarn.getEventId());
		return i;
	}

	@Override
	public void deleteEventWarnById(Integer eventId) {
		// TODO Auto-generated method stub
		eventWarnMapper.deleteByPrimaryKey(eventId);
	}

	@Override
	public List<EventWarn> getEventWarns(Integer userId) {
		// TODO Auto-generated method stub
		EventWarnExample example = new EventWarnExample();
		Criteria c = example.createCriteria();
		c.andUserIdEqualTo(userId);
		return eventWarnMapper.selectByExample(example);
	}

}
